package com.hua.config;

import com.hua.error.CustomException;
import com.hua.vo.ResponseResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

/**
 * @author ONE-X
 * @date 2020/11/11
 */
@RestControllerAdvice
public class MyRespExceptionHandler extends ResponseEntityExceptionHandler {

	@ExceptionHandler(CustomException.class)
	public ResponseResult customException(CustomException e) {
		return new ResponseResult(e.getR());
	}

	@ExceptionHandler(RuntimeException.class)
	public ResponseResult exception(RuntimeException e) {
		return ResponseResult.fail();
	}
}
